﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UI;

[InitializeOnLoad,System.Serializable]
public class UISystemEditor : EditorWindow
{
    private static UISettingsInfo _settings;

    static UISystemEditor()
    {
        _settings = Resources.Load<UISettingsInfo>("[UISystemSettings]");
        if (_settings == null)
        {
            _settings = CreateInstance<UISettingsInfo>();
            if (!System.IO.Directory.Exists("Assets/Resources"))
            {
                System.IO.Directory.CreateDirectory("Assets/Resources");
                AssetDatabase.Refresh();
            }
            AssetDatabase.CreateAsset(_settings, "Assets/Resources/[UISystemSettings].asset");
            System.IO.File.SetAttributes("Assets/Resources/[UISystemSettings].asset", System.IO.FileAttributes.ReadOnly);
        }
    }

    [MenuItem("UISystem/Settings")]
    private static void OpenSettings()
    {
        Selection.activeObject = _settings;
    }

}
